<template>
	<view class="page">
		<image src="../../static/register/top2.jpg" mode="widthFix" class="top" />
		<view class="location-container">
			<view class="left">
				<image src="../../static/register/location.png" mode="widthFix" class="location"></image>
				<text>代驾服务地点</text>
			</view>
			<view class="right">{{cityName}}</view>
		</view>
		<view class="info-container">
			<view class="title-container">
				<image src="../../static/register/title-bg.png" mode="widthFix" class="title-bg"></image>
				<text class="title">注册条件</text>
			</view>
			<view class="list">
				<view class="item">
					<text>1.</text>
					车辆合规合法；
				</view>
				<view class="item">
					<text>2.</text>
					年龄18岁以上；
				</view>
				<view class="item">
					<text>3.</text>
					无违法犯罪记录、无精神病史、无吸毒史，以及平台认为不适合使用代驾的其他历史证明；
				</view>
				
				
			</view>
		</view>
		<view class="info-container">
			<view class="title-container">
				<image src="../../static/register/title-bg.png" mode="widthFix" class="title-bg"></image>
				<text class="title">使用流程</text>
			</view>
			<view class="list">
				<view class="complex-item">
					<view class="left">01</view>
					<view class="right">
						<text class="item-title">在线注册账号</text>
						<text class="item-desc">在小程序完成注册</text>
					</view>
				</view>
				<view class="complex-item">
					<view class="left">02</view>
					<view class="right">
						<text class="item-title">个人信息填写</text>
						<text class="item-desc">按照流程提交本人身份证照片</text>
					</view>
				</view>
				<view class="complex-item">
					<view class="left">03</view>
					<view class="right">
						<text class="item-title">代驾下单</text>
						<text class="item-desc">通过APP下单预约代驾</text>
					</view>
				</view>
				<view class="complex-item">
					<view class="left">04</view>
					<view class="right">
						<text class="item-title">费用支付</text>
						<text class="item-desc">订单结束自动扣除费用</text>
					</view>
				</view>
			</view>
		</view>
		<!-- <button class="btn" @tap="wxLogin" >司机注册</button> -->
		<button class="btn" open-type="getPhoneNumber" @getphonenumber="phoneRegister" >微信注册</button>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
var QQMapWX = require('../../lib/qqmap-wx-jssdk.min.js');
var qqmapsdk;	
export default {
	data() {
		return {
			code: null,
			cityName:"哈尔滨"
		};
	},
	onLoad(){
		let _this = this;
		_this.initQQMapSDK();
		let location = _this.getAddress();
		_this.getPosition(location);
	
	},
	methods: {
		// 创建腾讯实例对象
		initQQMapSDK() {  
				qqmapsdk = new QQMapWX({  
					key: 'CVEBZ-EGPKJ-T36FO-DSNLG-N6Q6K-TIB4T' // 替换为您自己的key  
				});  
		}, 
		// 获取经纬度返回结果
		getAddress(){
			uni.getLocation({
				type: 'wgs84',
				success: function(res) {
					return res;
				}
			});
		},
		// 获取定位
		getPosition(location){
			const _this = this;
			qqmapsdk.reverseGeocoder({
				location:location,
				success: function(res){
					if(res.status == 0){
						_this.cityName = res.result.address_component.city
					}else{
						uni.showToast({
							icon: "error",
							title: "地址获取失败"
						})
					}
				}
			});
		},
		// 获取登录凭证code
		phoneRegister(e){
				let _this = this;
				// 清空本地储存
				uni.removeStorageSync("tokenName")
				uni.removeStorageSync("tokenValue")
				uni.removeStorageSync("permissions")
				uni.removeStorageSync("loginInfo")
				let phoneCode = e.detail.code // 动态令牌,个人开发者获取不了
				wx.login({
						success(res){
							// 拿授权码
							if(res.code){
								_this.get("customer/app/customer/register/"+ res.code + "/" + "15697077038",function(res){// 假数据模拟有动态令牌
									// 如果返回成功
									if(res.data.success){
										uni.showToast({
											title:"注册成功,请重写登录",
										})
										// 定时器2秒后执行
										setTimeout(function(){
											// 跳转到登录页面
											uni.navigateTo({
												url:"/pages/login/login"
											})
										},2000);
									// 如果不是
									}else{
										uni.showToast({
											icon:"error",
											title:"注册失败"
										})
										// 定时器2秒后执行
										setTimeout(function(){
											// 跳转到登录页面
											uni.navigateTo({
												url:"/pages/login/login"
											})
										},2000);
									}
								})
							}
						}
					})
			
		}
		
		
	}
};
</script>

<style lang="less">
@import url('register.less');
</style>
